package com.eastmoney.emis.edda.controller;

import com.eastmoney.emis.edda.application.vo.EddaBindVo;
import com.eastmoney.emis.edda.application.vo.EddaOtpRegenerationVo;
import com.eastmoney.emis.edda.application.service.EddaBindAndDirectDebitService;
import com.eastmoney.emis.edda.domain.service.edda.*;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: Description
 * @projectName: EDDA-HSBC
 * @package: com.eastmoney.emis.edda.controller
 * @author: 汪程程
 * @date: 2022/9/29 6:06 PM
 * @version: 1.0
 */
@RestController
@RequestMapping("/api/edda/hsbc")
@ApiOperation("HSBC EDDA申请")
public class HsbcEddaAuthController {

    @Autowired
    private EddaService eddaService;

    @Autowired
    private EddaBindAndDirectDebitService bindAndDirectDebitService;

    @PostMapping
    public EddaBindVo bind(@Validated @RequestBody EddaBindCommand eddaBindCommand) {
        return eddaService.bind(eddaBindCommand);
    }

    @PostMapping("/direct-debits")
    public EddaBindVo bindAndDirectDebit(@Validated @RequestBody EddaBindAndDirectDebitCommand bindAndDirectDebitCommand) {
        return bindAndDirectDebitService.bindAndDirectDebit(bindAndDirectDebitCommand);
    }

    @PostMapping("/otp/confirm")
    public void otpConfirm(@Validated @RequestBody EddaOtpConfirmCommand otpConfirmCommand) {
        eddaService.otpConfirm(otpConfirmCommand);
    }

    @PostMapping("/otp")
    public EddaOtpRegenerationVo otpRegeneration(@Validated @RequestBody EddaOtpRegenerationCommand regenerationCommand) {
        return eddaService.otpRegeneration(regenerationCommand);
    }
}
